﻿namespace Stock.WinForm
{
    using System.Collections.Generic;
    using System.Data;
    using System.Windows.Forms;
    using Stock.Bl;
    using Stock.Common;
    using Stock.Model;

    public partial class MyStockOptEdit : Form
    {
        public MyStockOptEdit()
        {
            InitializeComponent();

            DataGridViewColumn dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.Width = 160;
            dgvc.DataPropertyName = "Opt_Date";
            dgvc.HeaderText = "操作日期";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.Width = 120;
            dgvc.DataPropertyName = "Opt_Code";
            dgvc.HeaderText = "股票代码";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvc.Width = 120;
            dgvc.DataPropertyName = "S_Name";
            dgvc.HeaderText = "股票名称";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            //dgvc.DefaultHeaderCellType = DataGridViewContentAlignment.MiddleCenter;
            dgvc.Width = 80;
            dgvc.DataPropertyName = "Parameter_Name";
            dgvc.HeaderText = "操作类别";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 80;
            dgvc.DataPropertyName = "Opt_Copies";
            dgvc.HeaderText = "操作份额";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 100;
            dgvc.DataPropertyName = "Opt_Price";
            dgvc.HeaderText = "单价";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 100;
            dgvc.DataPropertyName = "Opt_Fee";
            dgvc.HeaderText = "手续费";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 120;
            dgvc.DataPropertyName = "Opt_Sum";
            dgvc.HeaderText = "此次合计";
            dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvc.HeaderCell.Style.WrapMode = DataGridViewTriState.False;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 120;
            dgvc.DataPropertyName = "Detail_Cd";
            dgvc.Visible = false;
            dataGridView1.Columns.Add(dgvc);

            dgvc = new DataGridViewTextBoxColumn();
            dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dgvc.Width = 120;
            dgvc.DataPropertyName = "Opt_type";
            dgvc.Visible = false;
            dataGridView1.Columns.Add(dgvc);

            dataGridView1.RowHeadersVisible = false;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.Lavender;//System.Drawing.Color.FromArgb(60, 250, 240, 230);
            //dataGridView1.AlternatingRowsDefaultCellStyle.SelectionBackColor = System.Drawing.Color.Fuchsia;
        }

        /// <summary>
        /// 限制输入为整数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void input_Integer_Press(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            e.Handled = true;
            if (char.IsDigit(e.KeyChar) || e.KeyChar == (char)0x08)
            {
                e.Handled = false;
            }
            if (e.KeyChar == 45)                       //负数
            {
                string txtValue = ((System.Windows.Forms.TextBox)sender).Text;

                if (txtValue.Length > 0)
                    e.Handled = true;           //只能是第一位
                else
                {
                    e.Handled = false;
                }
            }
        }

        /// <summary>
        /// 限制输入为浮点数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void input_float_Press(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8)
            {
                e.Handled = true;
            }

            if (e.KeyChar == 46)                       //小数点
            {
                string txtValue = ((System.Windows.Forms.TextBox)sender).Text;

                if (txtValue.Length <= 0)
                    e.Handled = true;           //小数点不能在第一位
                else
                {
                    float f;
                    float oldf;
                    bool b1 = false, b2 = false;
                    b1 = float.TryParse(txtValue, out oldf);
                    b2 = float.TryParse(txtValue + e.KeyChar.ToString(), out f);
                    if (b2 == true)
                    {
                        if (b1 == false)
                            e.Handled = true;
                        else
                            e.Handled = false;
                    }
                }
            }

            if (e.KeyChar == 45)                       //负数
            {
                string txtValue = ((System.Windows.Forms.TextBox)sender).Text;

                if (txtValue.Length > 0)
                    e.Handled = true;           //只能是第一位
                else
                {
                    e.Handled = false;
                }
            }
        }

        /// <summary>
        ///  初期装载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MyStockOptEdit_Load(object sender, System.EventArgs e)
        {
            StockOptDetailBl stockOptDetailBl = new StockOptDetailBl();
            string strWhere = string.Empty;

            System.DateTime oldDt = System.DateTime.Now.AddMonths(-3);
            strWhere += "StockOptDetail.Opt_Date >=" + oldDt.ToString("yyyyMMdd");

            DataSet dsList = stockOptDetailBl.GetDataList(strWhere);

            dataGridView1.DataSource = dsList.Tables[0];

            //setComboBox(this.comboBox1, false);
            setComboBox(this.comboBox2, true);

            IList<ComboBoxEntity> combox1 = new List<ComboBoxEntity>();

            ComboBoxEntity comboBoxEntity = new ComboBoxEntity();
            comboBoxEntity.CbKey = "0";
            comboBoxEntity.CbValue = "";

            combox1.Add(comboBoxEntity);

            comboBoxEntity = new ComboBoxEntity();
            comboBoxEntity.CbKey = "1";
            comboBoxEntity.CbValue = "AAAAAA";

            this.comboBox1.DataSource = combox1;

            comboBox1.DisplayMember = "CbValue";//显示项
            comboBox1.ValueMember = "CbKey";//值项
        }

        /// <summary>
        /// 设定生成的Combobox
        /// </summary>
        /// <param name="comboBox">Combobox对象</param>
        /// <param name="p">有无空白行</param>
        private void setComboBox(ComboBox comboBox, bool p)
        {
            StockOptDetailBl stockOptDetailBl = new StockOptDetailBl();
            DataSet dsList = stockOptDetailBl.GetTypeDataList("Parameter_Type='1'");
            DataTable dt = dsList.Tables[0];
            if (p)
            {
                System.Data.DataRow drNon = dt.NewRow();
                drNon["Parameter_Value"] = "";
                drNon["Parameter_Name"] = "";
                dt.Rows.InsertAt(drNon, 0);
            }

            if (dt != null)
            {
                comboBox.DataSource = dt;//绑定数据.
                comboBox.DisplayMember = "Parameter_Name";//显示项
                comboBox.ValueMember = "Parameter_Value";//值项
            }
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnQuit_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnQuery_Click(object sender, System.EventArgs e)
        {
            //dataGridView1.Rows.Remove();

            StockOptDetailBl stockOptDetailBl = new StockOptDetailBl();

            string strWhere = string.Empty;
            bool andFlg = false;
            if (this.radioButton1.Checked)
            {
                System.DateTime oldDt = System.DateTime.Now.AddMonths(-3);
                strWhere += "StockOptDetail.Opt_Date >=" + oldDt.ToString("yyyyMMdd");
                andFlg = true;
            }
            if ((this.textBox5.Text).Trim().Length > 0)
            {
                if (andFlg)
                {
                    strWhere += "  And ";
                }
                strWhere += "(StockOptDetail.Opt_Code like %" + (this.textBox5.Text).Trim() + "% ";
                strWhere += "OR Stock_Info.S_Name like %" + (this.textBox5.Text).Trim() + "% ";
                strWhere += "OR Stock_Info.S_PYM like %" + (this.textBox5.Text).Trim() + "% )";
                andFlg = true;
            }

            if (!(this.comboBox2.SelectedValue == null) && !this.comboBox2.SelectedValue.ToString().Trim().Equals(""))
            {
                if (andFlg)
                {
                    strWhere += "  And ";
                }
                strWhere += "(StockOptDetail.Opt_type  = '" + this.comboBox2.SelectedValue.ToString() + "' ";
                andFlg = true;
            }
            DataSet dsList = stockOptDetailBl.GetDataList(strWhere);

            dataGridView1.DataSource = dsList;
        }

        /// <summary>
        /// 清理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_Click(object sender, System.EventArgs e)
        {
            this.txtCd.Text = "";
            this.textBox1.Text = "";
            this.textBox2.Text = "";
            this.textBox4.Text = "";
            this.txtOptID.Text = "";
            this.dateTimePicker1.Value = System.DateTime.Now;
            this.comboBox1.SelectedIndex = 0;

            this.txtCd.ReadOnly = false;
            this.textBox1.ReadOnly = false;
            this.textBox2.ReadOnly = false;
            this.textBox4.ReadOnly = false;
            this.txtOptID.ReadOnly = false;
            this.dateTimePicker1.Enabled = true;
            this.comboBox1.Enabled = true;

            this.txtCd.BackColor = System.Drawing.Color.White;
            this.textBox1.BackColor = System.Drawing.Color.White;
            this.textBox2.BackColor = System.Drawing.Color.White;
            this.textBox4.BackColor = System.Drawing.Color.White;
            this.dateTimePicker1.BackColor = System.Drawing.Color.White;
            this.comboBox1.BackColor = System.Drawing.Color.White;
        }

        private decimal setEntityValue(TextBox tx)
        {
            decimal toValue = 0;
            if (tx.Text.Trim().Length > 0)
            {
                toValue = decimal.Parse(tx.Text.Trim());
            }
            return toValue;
        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            Stock.Model.StockOptDetailEntity stockOptDetailEntity = new Model.StockOptDetailEntity();
            Stock.Model.StockOptDetailEntity oldOptDetailEntity = new Model.StockOptDetailEntity();
            StockOptDetailBl stockOptDetailBl = new StockOptDetailBl();

            stockOptDetailEntity.S_Code = this.txtCd.Text;
            stockOptDetailEntity.Opt_type = this.comboBox1.SelectedValue.ToString();
            if (this.textBox1.Text.Trim().Length > 0)
            {
                stockOptDetailEntity.Opt_Copies = int.Parse(this.textBox1.Text);
            }
            else
            {
                stockOptDetailEntity.Opt_Copies = 0;
            }
            stockOptDetailEntity.Opt_Date = this.dateTimePicker1.Value.ToString("yyyyMMdd");

            stockOptDetailEntity.Opt_Fee = setEntityValue(textBox4);
            stockOptDetailEntity.Opt_Price = setEntityValue(textBox2);
            stockOptDetailEntity.Opt_Profit = setEntityValue(textBox7);
            stockOptDetailEntity.Opt_Bonus = setEntityValue(textBox8);
            stockOptDetailEntity.Opt_Convertable = setEntityValue(textBox9);

            //取得这次操作的总费用
            stockOptDetailEntity.Opt_Sum = stockOptDetailEntity.Opt_Copies * stockOptDetailEntity.Opt_Price
                - stockOptDetailEntity.Opt_Fee + stockOptDetailEntity.Opt_Profit;

            stockOptDetailEntity.User_Code = Const.USER_CODE;
            //if (this.txtOptID.Text.Trim().Length > 0)
            //{
            //    stockOptDetailEntity = stockOptDetailBl.GetModel(int.Parse(this.txtOptID.Text));
            //    //Update
            //    stockOptDetailBl.UpdateStockOptDetail(stockOptDetailEntity, oldOptDetailEntity);
            //}
            //else
            //{
            //    //Add
            //    stockOptDetailBl.AddStockOptDetail(stockOptDetailEntity);
            //}

            string strWhere = string.Empty;

            System.DateTime oldDt = System.DateTime.Now.AddMonths(-3);
            strWhere += "StockOptDetail.Opt_Date >=" + oldDt.ToString("yyyyMMdd");

            DataSet dsList = stockOptDetailBl.GetDataList(strWhere);

            dataGridView1.DataSource = dsList.Tables[0];
            //#region OptTable

            //if (this.txtOptID.Text.Trim().Length > 0)
            //{
            //    stockOptDetailEntity = stockOptDetailBl.GetModel(int.Parse(this.txtOptID.Text));
            //    //stockOptDetailEntity.Detail_Cd = int.Parse(this.txtOptID.Text);
            //    if (this.textBox4.Text.Trim().Length > 0)
            //    {
            //        stockOptDetailEntity.Opt_Fee = decimal.Parse(this.textBox4.Text);
            //    }
            //    else
            //    {
            //        stockOptDetailEntity.Opt_Fee = 0;
            //    }
            //    stockOptDetailBl.Update(stockOptDetailEntity);
            //}
            //else
            //{
            //    stockOptDetailEntity.Opt_Code = this.txtCd.Text;
            //    if (this.textBox1.Text.Trim().Length > 0)
            //    {
            //        stockOptDetailEntity.Opt_Copies = int.Parse(this.textBox1.Text);
            //    }
            //    stockOptDetailEntity.Opt_Date = this.dateTimePicker1.Value.ToString("yyyyMMdd");
            //    if (this.textBox4.Text.Trim().Length > 0)
            //    {
            //        stockOptDetailEntity.Opt_Fee = decimal.Parse(this.textBox4.Text);
            //    }
            //    else
            //    {
            //        stockOptDetailEntity.Opt_Fee = 0;
            //    }
            //    if (this.textBox2.Text.Trim().Length > 0)
            //    {
            //        stockOptDetailEntity.Opt_Price = decimal.Parse(this.textBox2.Text);
            //    }

            //    stockOptDetailEntity.Opt_Sum = decimal.Parse(stockOptDetailEntity.Opt_Price.ToString()) * int.Parse(stockOptDetailEntity.Opt_Copies.ToString()) + decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //    stockOptDetailEntity.Opt_type = this.comboBox1.SelectedValue.ToString();
            //    stockOptDetailBl.Add(stockOptDetailEntity);
            //}

            //#endregion OptTable

            //#region MyStockTable

            //MyStockEntity myStockEntity = new MyStockEntity();

            //Stock.Dal.MyStockDal myStockDal = new Stock.Dal.MyStockDal();
            //bool isExistsData = myStockDal.Exists(txtCd.Text);

            //#region 买入

            //if (this.comboBox1.SelectedValue.ToString().Equals("1"))
            //{
            //    //买入
            //    if (isExistsData)//Update
            //    {
            //        //取得原始数据
            //        myStockEntity = myStockDal.GetModel(txtCd.Text);
            //        myStockEntity.Copies = myStockEntity.Copies + int.Parse(this.textBox1.Text);
            //        myStockEntity.InAmount = myStockEntity.InAmount + decimal.Parse(stockOptDetailEntity.Opt_Price.ToString()) * int.Parse(stockOptDetailEntity.Opt_Copies.ToString());
            //        myStockEntity.FeeSum = myStockEntity.FeeSum + decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //        myStockDal.Update(myStockEntity);
            //    }
            //    else//Add
            //    {
            //        myStockEntity.Copies = int.Parse(this.textBox1.Text);
            //        myStockEntity.InAmount = decimal.Parse(stockOptDetailEntity.Opt_Price.ToString()) * int.Parse(stockOptDetailEntity.Opt_Copies.ToString());
            //        myStockEntity.FeeSum = decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //        myStockEntity.S_Code = txtCd.Text;
            //        myStockEntity.My_Code = int.Parse(txtCd.Text);
            //        myStockDal.Add(myStockEntity);
            //    }
            //}

            //#endregion 买入

            //#region 卖出

            //if (this.comboBox1.SelectedValue.ToString().Equals("2"))
            //{
            //    //卖出
            //    if (isExistsData)//Update
            //    {
            //        //取得原始数据
            //        myStockEntity = myStockDal.GetModel(txtCd.Text);
            //        myStockEntity.Copies = myStockEntity.Copies - int.Parse(this.textBox1.Text);
            //        myStockEntity.OutAmount = myStockEntity.OutAmount + decimal.Parse(stockOptDetailEntity.Opt_Price.ToString()) * int.Parse(stockOptDetailEntity.Opt_Copies.ToString());
            //        myStockEntity.FeeSum = myStockEntity.FeeSum + decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //        myStockDal.Update(myStockEntity);
            //    }
            //    else//Add
            //    {
            //        myStockEntity.Copies = int.Parse(this.textBox1.Text);
            //        myStockEntity.OutAmount = decimal.Parse(stockOptDetailEntity.Opt_Price.ToString()) * int.Parse(stockOptDetailEntity.Opt_Copies.ToString());
            //        myStockEntity.FeeSum = decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //        myStockEntity.S_Code = txtCd.Text;
            //        myStockEntity.My_Code = int.Parse(txtCd.Text);
            //        myStockDal.Add(myStockEntity);
            //    }
            //}

            //#endregion 卖出

            //#region 分红

            //if (this.comboBox1.SelectedValue.ToString().Equals("3"))
            //{
            //    //分红
            //    if (isExistsData)//Update
            //    {
            //        //取得原始数据
            //        myStockEntity = myStockDal.GetModel(txtCd.Text);
            //        myStockEntity.OutAmount = myStockEntity.OutAmount + decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString());
            //        myStockDal.Update(myStockEntity);
            //    }
            //}

            //#endregion 分红

            //#region 配股

            //if (this.comboBox1.SelectedValue.ToString().Equals("3"))
            //{
            //    //配股
            //    if (isExistsData)//Update
            //    {
            //        //取得原始数据
            //        myStockEntity = myStockDal.GetModel(txtCd.Text);
            //        myStockEntity.Copies = myStockEntity.Copies + decimal.Parse(stockOptDetailEntity.Opt_Fee.ToString()) * myStockEntity.Copies;
            //        myStockDal.Update(myStockEntity);
            //    }
            //}

            //#endregion 配股

            //#endregion MyStockTable
        }

        /// <summary>
        /// 双击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            this.txtCd.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
            this.textBox1.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
            this.textBox2.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
            this.textBox4.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
            this.txtOptID.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); ;
            this.dateTimePicker1.Value = System.DateTime.Parse(dataGridView1.SelectedRows[0].Cells[1].Value.ToString());
            this.comboBox1.SelectedValue = dataGridView1.SelectedRows[0].Cells[4].Value;

            this.txtCd.ReadOnly = true;
            this.textBox1.ReadOnly = true;
            this.textBox2.ReadOnly = true;
            //this.textBox4.ReadOnly = true;
            this.txtOptID.ReadOnly = true;
            this.dateTimePicker1.Enabled = false;
            this.comboBox1.Enabled = false;

            this.txtCd.BackColor = System.Drawing.Color.LightGray;
            this.textBox1.BackColor = System.Drawing.Color.LightGray;
            this.textBox2.BackColor = System.Drawing.Color.LightGray;
            // this.textBox4.BackColor = System.Drawing.Color.LightGray;
            this.dateTimePicker1.BackColor = System.Drawing.Color.LightGray;
            this.comboBox1.BackColor = System.Drawing.Color.LightGray;
        }

        private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            /*
             * 1、买入和卖出，产生费用和份数以及单价
             * 2、分红只产生费用
             * 3、配股只产生份额比例
             *
             */
            if (comboBox1.SelectedValue.Equals("1"))
            {
                this.textBox1.Text = "";
                this.textBox2.Text = "";
                this.textBox4.Text = "";
                //this.textBox1.Enabled = true;
                //this.textBox2.Enabled = true;

                label10.Visible = label11.Visible = label12.Visible = textBox7.Visible = false;
                textBox8.Visible = textBox9.Visible = false;

                label6.Visible = textBox4.Visible = true;
            }
            else if (comboBox1.SelectedValue.Equals("2"))
            {
                this.textBox1.Text = "";
                this.textBox2.Text = "";
                this.textBox4.Text = "";

                //this.textBox1.Enabled = true;
                //this.textBox2.Enabled = true;

                label10.Visible = label11.Visible = label12.Visible = textBox7.Visible = false;
                textBox8.Visible = textBox9.Visible = false;

                label6.Visible = textBox4.Visible = true;
            }
            else if (comboBox1.SelectedValue.Equals("3"))
            {
                this.textBox1.Text = "";
                this.textBox2.Text = "";
                this.textBox4.Text = "";

                //this.textBox1.Enabled = false;
                //this.textBox2.Enabled = false;

                label10.Visible = label11.Visible = label12.Visible = textBox7.Visible = true;
                textBox8.Visible = textBox9.Visible = true;

                label6.Visible = textBox4.Visible = false;
            }
            //else if (comboBox1.SelectedValue.Equals("4"))
            //{
            //    this.label6.Text = "转增股";

            //    this.textBox1.Text = "";
            //    this.textBox2.Text = "";
            //    this.textBox4.Text = "";

            //    this.textBox1.Enabled = false;
            //    this.textBox2.Enabled = false;
            //}
            //else if (comboBox1.SelectedValue.Equals("5"))
            //{
            //    this.label6.Text = "送股";

            //    this.textBox1.Text = "";
            //    this.textBox2.Text = "";
            //    this.textBox4.Text = "";

            //    this.textBox1.Enabled = false;
            //}
        }

        private void textBox6_Leave(object sender, System.EventArgs e)
        {
            StockOptDetailBl StockOptDetailBl = new StockOptDetailBl();

            StockInfoEntity ste = StockOptDetailBl.GetStockByKey(textBox6.Text);
            if (ste == null)
            {
                return;
            }
            this.txtCd.Text = ste.S_Code;
            this.textBox3.Text = ste.S_Name;
            this.textBox6.Text = ste.S_PYM;
        }
    }
}